package com.newbsd.web.maventest.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.newbsd.web.maventest.pojo.Manager;
import com.newbsd.web.maventest.service.ManagerService;
import com.newbsd.web.maventest.service.impl.ManagerServiceImpl;

/**
 *@author Mei
 */
@WebServlet("/addAdminServlet")
public class addAdminServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		response.getWriter().append("Served at: ").append(request.getContextPath());
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		
		Manager manager = new Manager();
		manager.setmName(request.getParameter("mName"));
		manager.setmPassword(request.getParameter("mPassword"));
		manager.setManagerId(Integer.parseInt(request.getParameter("managerId")));
		manager.setSex(request.getParameter("sex"));
		
		ManagerService managerService = new ManagerServiceImpl();
		managerService.updateAdmin(manager);
		request.getRequestDispatcher("/Admin/userQuery.jsp").forward(request, response);
	}

}
